package top.tagao.m03_beHavioralPatterns.b_13chain.middleware;

/**
 * @author Viktor.Liu
 * @Date 2023/4/28 17:01
 */
public abstract  class  MiddleWare {

    private MiddleWare next;


    public static MiddleWare link(MiddleWare first, MiddleWare... chain){
        MiddleWare head = first;
        for (MiddleWare nextChain : chain) {
            head.next = nextChain;
            head = nextChain;
        }
        return first;
    }

    //handle（request） 处理方法
    public abstract  boolean handle(String email, String password);

    //handleNext 下个处理者
    protected  boolean handleNext(String email, String password){
        if(next == null) return true;

        return next.handle(email, password);
    }

}
